<template>
  <div class="time-line-wrap">
    <div :class="{'time-line-active': item.isActive}" class="time-line-item" @click="getItem(item)" v-for="(item, index) in props.timeLineArr" :key="index">
      <div class="left">
        <div class="circle"></div>
        <div class="line" v-if="index < props.timeLineArr.length - 1"></div>
      </div>
      <div class="right">
        <div class="time">
          <span>{{item.time}}</span>
          <template v-if="props.isQuestion">
            <span class="question-res apply" v-if="item.isApply">已答复</span>
            <span class="question-res not-apply" v-if="!item.isApply">未答复</span>
          </template>
        </div>
        <div class="content">
          <span>{{item.content}}</span>
        </div>
      </div>
    </div>
  </div>
</template>


<script lang="ts" setup>

import {defineProps} from 'vue'


const props = defineProps<{
  timeLineArr: [],
  isQuestion: boolean
}>()
const emit = defineEmits(['clinkItem'])
const getItem = (item) => {
  emit('clinkItem', item)
}
</script>

<style lang="scss" scoped>
.time-line-wrap {
  cursor: pointer;
  max-height: 420px;
  overflow-y: auto;
  .time-line-item {
    height: 70px;
    display: flex;
    align-items: stretch;
    position: relative;
    cursor: pointer;
    padding: 0 7px;
    width: 88%;
    border: 1px solid transparent;
    &.time-line-active {
      background: rgba(64, 158, 255, 0.3);
      border: 1px solid #409EFF;
    }
    .left {
      height: 100%;
      position: relative;
      width: 12px;
      .circle {
        width: 12px;
        height: 12px;
        border-radius: 12px;
        background-color: #409EFF;
      }
      .line {
        position: absolute;
        width:1px;
        border: 2px solid rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.2);
        left: 4px;
        height: 64px;
      }
    }
    .right {
      flex: 1;
      padding-left: 12px;
      .time {
        font-size: 14px;
        letter-spacing: 0;
        color: #FFFFFF;
        height: 22px;
        line-height: 24px;
      }
      .question-res {
        display: inline-block;
        margin-left: 8px;
        font-size: 10px;
        height: 14px;
        line-height: 14px;
        padding: 1px 2px;
        border-radius: 2px;
        &.apply {
          background: rgba(97, 197, 166, 0.5);
        }
        &.not-apply {
          background: rgba(247, 169, 93, 0.5);
        }
      }
      .content {
        font-size: 13px;
        line-height: 24px;
        color: #e9e9e9;
        margin-left: 8px;
      }
    }
  }
}

</style>
